package com.shuzixiangcun.service.admin;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.shuzixiangcun.entity.HealthRecords;
import com.shuzixiangcun.dao.HealthRecordsDao;
import com.shuzixiangcun.entity.JobApplications;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (HealthRecords)表服务实现类
 *
 * @author makejava
 * @since 2024-07-03 14:39:35
 */
@Service
public class HealthRecordsServiceImpl {
    @Resource
    private HealthRecordsDao healthRecordsDao;

    /**
     * 通过ID查询单条数据
     *
     * @param 主键
     * @return 实例对象
     */

    public HealthRecords queryById(Integer id) {
        return this.healthRecordsDao.queryById(id);
    }



    /**
     * 新增数据
     *
     * @param healthRecords 实例对象
     * @return 实例对象
     */

    public HealthRecords insert(HealthRecords healthRecords) {
        this.healthRecordsDao.insert(healthRecords);
        return healthRecords;
    }

    /**
     * 修改数据
     *
     * @param healthRecords 实例对象
     * @return 实例对象
     */

    public HealthRecords update(HealthRecords healthRecords) {
        this.healthRecordsDao.update(healthRecords);
        return this.queryById(healthRecords.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param 主键
     * @param id
     * @return 是否成功
     */

    public boolean deleteById(Integer id) {
        return this.healthRecordsDao.deleteById(id) > 0;
    }


    public List<HealthRecords> getList(Integer user_id) {
        return this.healthRecordsDao.queryListHealths(user_id);
    }

    public PageInfo<HealthRecords> getPageInfo(Integer pageNo, Integer pageSize) {
        PageHelper.startPage(pageNo, pageSize,true);
        List<HealthRecords> mangerList=healthRecordsDao.getPageInfo();
        return new PageInfo<HealthRecords>(mangerList);
    }

    public int updateByState(HealthRecords healthRecords) {

        return this.healthRecordsDao.updateByState(healthRecords);
    }
}
